<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>产废点收集情况</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .laytable-cell-radio.layui-table-cell {
            padding: 0 5px 0 15px;
        }
        
        .laytable-cell-radio span {
            display: none;
        }
        
        .laytable-cell-radio .layui-form-radio {
            padding-right: 0;
            margin: 0;
        }
        
        .layui-form-select dl dd.layui-this {
            background-color: #1e9FFF;
        }
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">收集日期</label>
            <div class="layui-inline">
                <input type="text" class="layui-input" id="datetime" placeholder="请选择日期">
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;监测单位
            <div class="layui-inline" style="width:300px">
                <select name="custid" id="select" style="width:300px" class="layui-input" lay-search>
								<option value=""></option>
							</select>
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch"><i class="layui-icon">&#xe615;</i>查询</button>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime', //指定元素
                theme: '#1E9FFF'
            });
        });
        $.ajax({
            url: "../../../Cust/hospital",
            dataType: 'json',
            type: "get",
            success: function(res) {
                $.each(res.data, function(index) {
                    var id = res.data[index].hid;
                    var name = res.data[index].name;
                    $("#select").append("<option value='" + id + "'>" + name + "</option>")
                });
                layui.form.render();
            }

        })

        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;

            var tableIns = table.render({
                elem: '#demo',
                height: 'full-80',
                data: [],
                cols: [
                    [ //表头
                        {
                            field: 'custname',
                            title: '产废点名称',
                            width: "8%"
                        }, {
                            field: 'ctime',
                            title: '收集时间',
                            width: "10%"

                        }, {
                            field: 'cname',
                            title: '收集人员',
                            width: "8%"

                        }, {
                            field: 'sname',
                            title: '审核人员',
                            width: "10%"
                        }, {

                            title: '医疗废物合计',
                            width: "10%",
                            align: 'center',
                            templet: function(d) {
                                return (parseInt(d.num_0) + parseInt(d.num_1) + parseInt(d.num_3) + parseInt(d.num_4) + parseInt(d.num_5)) + " 箱 / " + (parseFloat(d.wei0) + parseFloat(d.wei1) + parseFloat(d.wei3) + parseFloat(d.wei4) + parseFloat(d.wei5)) + " Kg"
                            }
                        }, {
                            field: 'num_0',
                            title: '感染性废物',
                            width: "10%",
                            align: 'center',
                            templet: function(d) {
                                if (d.num_0 == "" || d.num_0 == null) {
                                    return "0 箱 / 0 Kg";
                                } else {
                                    return d.num_0 + " 箱 /" + parseFloat(d.wei0) + "Kg";
                                }

                            }
                        }, {
                            field: 'num_1',
                            title: '损伤性废物（利器盒）',
                            width: "11%",
                            align: 'center',
                            templet: function(d) {
                                if ((d.num_1 == "" || d.num_1 == null) && (d.nval1_2 == "" || d.nval1_2 == null)) {
                                    return "0 箱( 0 只) /0 Kg";
                                } else if ((d.num_1 == "" || d.num_1 == null) && (d.nval1_2 != "" || d.nval1_2 != null)) {
                                    return "0 箱( " + d.nval1_2 + "只) / 0 Kg"
                                } else if ((d.num_1 != "" || d.num_1 != null) && (d.nval1_2 == "" || d.nval1_2 == null)) {
                                    return d.num_1 + " 箱( 0 只) /" + d.wei1 + "Kg"
                                } else {
                                    return d.num_1 + " 箱 ( " + d.nval1_2 + " 只) /" + d.wei1 + " Kg";
                                }

                            }
                        }, {
                            field: 'num_5',
                            title: '病理性废物（胎盘）',
                            width: "10%",
                            align: 'center',
                            templet: function(d) {
                                if ((d.num_5 == "" || d.num_5 == null) && (d.nval1_5 == "" || d.nval1_5 == null)) {
                                    return "0 箱(0 只) / 0 Kg";
                                } else if ((d.num_5 == "" || d.num_5 == null) && (d.nval1_5 != "" || d.nval1_5 != null)) {
                                    return "0 箱(" + d.nval1_5 + " 只) / 0 Kg"
                                } else if ((d.num_5 != "" || d.num_5 != null) && (d.nval1_5 == "" || d.nval1_5 == null)) {
                                    return d.num_5 + " 箱 (0 只) / " + d.wei5 + " Kg"
                                } else {
                                    return d.num_5 + " 箱(" + d.nval1_5 + " 只) / " + d.wei5 + " Kg";
                                }

                            }
                        }, {
                            field: 'num_4',
                            title: '药物性废物',
                            width: "10%",
                            align: 'center',
                            templet: function(d) {
                                if (d.num_4 == "" || d.num_4 == null) {
                                    return "0 箱 / 0 Kg";
                                } else {
                                    return d.num_4 + " 箱 / " + d.wei4 + "Kg";
                                }

                            }
                        }, {
                            field: 'num_3',
                            title: '化学性废物',
                            width: "10%",
                            align: 'center',
                            templet: function(d) {
                                if (d.num_3 == "" || d.num_3 == null) {
                                    return "0 箱 / 0 Kg";
                                } else {
                                    return d.num_3 + " 箱 / " + d.wei3 + " Kg";
                                }

                            }
                        }
                    ]
                ],
                skin: 'row', //表格风格				
                even: true,
            });
            $("#serch").on('click', function() {
                tableIns.reload({
                    url: '../../../Collect/hcustcollect',
                    where: {
                        date: $("#datetime").val(),
                        custid: $("#select option:selected").val()
                    } //设定异步数据接口的额外参数

                });
                $("table thead tr").css({
                    "background": "#1E9FFF",
                    "color": "white"
                });
            });


            $("table thead tr").css({
                "background": "#1E9FFF",
                "color": "white"
            });

        });
    </script>
</body>

</html>